define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope,Myagentdistributor_order,$stateParams,$timeout,GoDialog,GoPage) {
     	$scope.type = "";
     	$scope.order_id = $stateParams.order_id;
     	$scope.store_id = $stateParams.store_id;
     	
     	//得到当前身份
     	$scope.user_type = "";
		$scope.user_type_id = $stateParams.user_type_id;
		switch($scope.user_type_id){
			case '1':
				$scope.user_type = "制造商";
				break;
			case '2':
				$scope.user_type = "品牌代理商";
				break;
			case '3':
				$scope.user_type = "代理商";
				break;
			case '4':
				$scope.user_type = "经销商";
				break;
			case '5':
				$scope.user_type = "终端";
				break;
		}
     	
     	$scope.init_data = function() {
			Myagentdistributor_order.get_order($scope.order_id, $scope.store_id,function(data) {
				$scope.order = data;
				if(data.order_type == 'normal'){
					$scope.type = 'goods';
				}
//				console.log(data)
			});
		}
		$scope.init_data(); //必须在定义之后
		
		$scope.onshow_first = function(){
			GoPage.go_states("first", { "store_id": $scope.store_id});
		}
		
		$scope.onshow_productdetail = function(goods_id){
			GoPage.go_states("productdetail", { "goods_id": goods_id, "type": $scope.type });
		}
	}

	controller.$inject = ['$scope', 'Myagentdistributor_order','$stateParams','$timeout','GoDialog','GoPage'];
	
	return app.registerController("myagentdistributor_orderctrl",controller);
});